from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Response


class StudentPageNumberPagination(PageNumberPagination):
    # 查询字符串中代表页码的变量名，默认是 page
    page_query_param = "pagenum"
    # 查询字符串中代表每一页数据的变量名, 默认是page_size
    page_size_query_param = "pagesize"
    # 默认分页的每一页数据量, 查询字符串未设置时生效
    page_size = 8
    # 允许客户端通过查询字符串调整的最大单页数据量
    max_page_size = 20

    def get_paginated_response(self, data):
        return Response({
            'total': self.page.paginator.count,
            'results': data
        })

